﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="schedulingInfoManager.aspx.cs" Inherits="RegisterWeb.Manager.SchedulingInfoManager.schedulingInfoManager" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head id="Head1" runat="server">
    <title></title>
    <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>

<script type="text/javascript">

    var url; //提交数据的路径
    var formId; //当天要提交的Form的编号
    var dialogId; //对话框的编号

    var successCallback = function (result) {
        //result为请求处理后的返回值
        var result = eval('(' + result + ')');
        if (result.success) {
            $.messager.show({
                title: 'Success',
                msg: result.msg
            });
            $(dialogId).dialog('close');
            $('#dg').datagrid('reload');
        } else {
            $.messager.show({
                title: 'Error',
                msg: result.msg
            });
        }
    }

    $(function () {
        //预加载编辑框
        $("#addSchedulingInfo").dialog({
            "title": "编辑医生安排信息",
            width: 600,
            height: 400,
            href: 'EditSchedulingInfo.aspx'
        });
        $("#addSchedulingInfo").dialog('open').dialog('close');

        $('#dg').datagrid({

            onDblClickRow: function (rowIndex, rowData) {
                $('#addSchedulingInfo').dialog('open');
                $('#Doctor_Name').combobox('setValue', rowData.Doctor_ID);
                $('#Type').combobox('setValue', rowData.TimeType);
                $("#DayTime").datebox('setValue', rowData.DayTime);

                url = 'ashx/SchedulingInfoManagerService.ashx?action=edit&id=' + rowData.ID;
                formId = "#add";
                dialogId = "#addSchedulingInfo";

            }
        });

    });
    //编辑医生安排部分
    function editSchedulingInfo() {

        var row = $('#dg').datagrid('getSelected');

        if (row) {

            $('#addSchedulingInfo').dialog('open');
            $('#Doctor_Name').combobox('setValue', row.Doctor_ID);
            $('#Type').combobox('setValue', row.TimeType);
            $("#DayTime").datebox('setValue', row.DayTime);

            url = 'ashx/SchedulingInfoManagerService.ashx?action=edit&id=' + row.ID;
            formId = "#add";
            dialogId = "#addSchedulingInfo";
        }
        else {
            $.messager.alert("提示", "您没有选中任何行！");
        }
    }

    //生成医生安排
    function schedulingInfo() {
        var Type = document.getElementsByName("SchedulingInfo")[0].value;
        $('#dg').datagrid('options').pageNumber = 1;
        $('#dg').datagrid('getPager').pagination({ pageNumber: 1 });

        $('#dg').datagrid('options').url = 'ashx/SchedulingInfoManagerService.ashx?action=add&Type=' + Type;
        $('#dg').datagrid("reload");
    }

    function saveInfo() {
        $(formId).form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: successCallback
        });
    }


    //多条件查询方法
    function tsearch() {
        var TimeType = $("#MyType").combobox("getValue");
        var Doctor_ID = $("#MyDoctor_Name").combobox("getValue");
        var Begin = $("#Begin").datebox("getValue");
        var End = $("#End").datebox("getValue");
        $('#dg').datagrid('options').pageNumber = 1;
        $('#dg').datagrid('getPager').pagination({ pageNumber: 1 });
        $('#dg').datagrid('options').url = 'ashx/SchedulingInfoManagerService.ashx?action=search&TimeType=' + TimeType + '&Doctor_ID=' + Doctor_ID + '&Begin=' + Begin + '&End=' + End;
        $('#dg').datagrid("reload");
    }

</script>

</head>
<body>
    <form id="form1">
    <div region="center" title="医生安排管理" >
<table id="dg" title="医生安排管理" class="easyui-datagrid" style="overflow:auto; height:550px"
			url="ashx/SchedulingInfoManagerService.ashx?action=list"
			toolbar="#toolbar" pagination="true"
			rownumbers="true" fitColumns="true" singleSelect="true"   idField='ID'
            pageSize="20"
            >
		<thead>
			<tr>
				<th field="ID" width="50">编号</th>
				<th field="Departments_Name" width="50">部门</th>
                <th field="Doctor_Name" width="50">医生</th>
				<th field="TextTimeType" width="50">时间类型</th>
                <th field="DayTime" width="50">日期</th>
                <th field="TextOutpatientType" width="50">门诊类型</th>
                <th field="RegisteredNumber" width="50">可挂号数量</th>
                <th field="ConfirmStatus" width="50">医生是否确认</th>

                <th field="Departments_ID" width="50" hidden='true'>部门ID</th>
                <th field="Doctor_ID" width="50" hidden='true'>医生ID</th>
                <th field="OutpatientType" width="50" hidden='true'>门诊类型ID</th>
			</tr>
		</thead>
	</table>

    <div id="toolbar" style="padding:5px;height:auto">
                    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editSchedulingInfo()">医生安排调整</a>
    


			<div id="addSchedulingInfo" class="easyui-dialog" closed="true" buttons="#addSchedulingInfo-buttons" style="padding:10px 20px">
        	</div>
			<div id="addSchedulingInfo-buttons">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveInfo()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#addSchedulingInfo').dialog('close')">关闭</a>
			</div>
        <div>
        	自动排班时间选择: 
			<select name="SchedulingInfo" id="SchedulingInfo" style="width:150px;">
            <option value="1" selected='selected'>未来一周</option>
            <option value="2" >未来两周</option>
            <option value="3" >未来三周</option>
            </select>
            
			<a href="#" class="easyui-linkbutton" iconCls="icon-tip" onclick="schedulingInfo()">生成医生安排</a>
        </div>
        </div>
    </div>
    </form>
</body>
</html>
